<template>
    <div>
        <transition name="van-slide-right">
            <router-view/>
        </transition>
        <van-search v-model="search_word"
                    :placeholder="placeholderVal"
                    shape="round"
                    disabled
                    @click="$router.push('/searchPopup')"/>
        <van-swipe :autoplay="3000">
            <van-swipe-item v-for="(val,index) in banner" :key="index">
                <van-image height="100%" :src="val.image_url"/>
            </van-swipe-item>
        </van-swipe>
        <Grid/>
        <Topic :topicList="topicList"/>
    </div>
</template>

<script>
import {GetHishotData, GetHomeData} from "@/api/home";
import Grid from "@/components/home/Grid";
import Topic from "@/components/home/Topic";

export default {
    name: "HomeView",
    components: {Topic, Grid},
    data() {
        return {
            search_word: "",
            banner: [],
            placeholderVal: "",
            topicList: [],
        }
    },
    beforeCreate() {
        GetHomeData().then(res => {
            this.banner = res.data.banner;
            this.topicList = res.data.topicList;
        });
        GetHishotData().then(res => {
            this.placeholderVal = res.data.defaultKeyword.keyword;
        })
    }

};
</script>

<style lang="less">

</style>
